<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>批量提交到后台</title>
</head>
<body>
<div id="app">
    <button @click="userList.push({})">+</button>
    <table>
        <thead>
        <tr>
            <th>用户名</th>
            <th>年龄</th>
            <th>生日</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="u in userList">
            <td><input type="text" v-model="u.username" name="username"/></td>
            <td><input type="text" v-model="u.age" name="age"/></td>
            <td><input type="datetime" v-model="u.birthday" name="birthday"/></td>
        </tr>
        </tbody>
        <tfoot>
        <tr>
            <td colspan="4">
                <button @click="handleSubmit">提交</button>
            </td>
        </tr>
        </tfoot>
    </table>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            userList: [{}]
        },
        methods: {
            handleSubmit: function () {
                axios.post('/userList', JSON.stringify(this.userList),
                    {headers: {"Content-Type": "application/json; charset=utf8"}})
                    .then(function (response) {
                        console.log(response);
                    })
            }
        }
    })
</script>
</body>
</html>